/**
 * Copyright (C), 2015-2020, XXX有限公司
 * FileName: OrderContoller
 * Author:   sky
 * Date:     2020/4/18 22:32
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package cn.szh.controller;


import cn.szh.domain.Order;
import cn.szh.domain.Product;
import cn.szh.service.OrderService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.security.RolesAllowed;
import java.util.List;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author sky
 * @create 2020/4/18
 * @since 1.0.0
 */
@Controller
@RequestMapping("/order")
public class OrderContoller {
    @Autowired
    private OrderService orderService;
    //未分页
//    @RequestMapping("/findAll.do")
//    public ModelAndView findAll(){
//        ModelAndView mv =new ModelAndView();
//        List<Order> orderList = orderService.findAll();
//        mv.addObject("ordersList",orderList);
//        mv.setViewName("orders-list");
//        return mv;
//    }
      @RequestMapping("/findAll.do")
      @RolesAllowed("ADMIN")
      public ModelAndView findAll(@RequestParam(name = "pageNum",required = true)Integer pageNum,
                                  @RequestParam(name = "pageSize",required = true)Integer pageSize){
          ModelAndView mv =new ModelAndView();
          System.out.println(pageNum);
          List<Order> orderList = orderService.findAllByPage(pageNum,pageSize);
          PageInfo pageInfo=new PageInfo(orderList);
          mv.addObject("pageInfo",pageInfo);
          mv.setViewName("orders-list");
          return mv;
      }
}
